import request from '@/utils/request'

// 获取商品最新信息
export const getNewCartGoods = (skuId) => {
  return request(`/goods/stock/${skuId}`, 'get')
}

// 根据skuID获取商品信息
export const getGoodsSku = (skuId) => {
  return request(`/goods/sku/${skuId}`, 'get')
}

// 合并本地购物车
export const mergeLocalCart = (cartList) => {
  return request('/member/cart/merge', 'post', cartList)
}

// 获取购物车列表
export const findCartList = () => {
  return request('/member/cart', 'get')
}

// 加入购物车
export const insertCart = ({ skuId, count }) => {
  return request('/member/cart', 'post', { skuId, count })
}

// 删除商品
export const deleteCart = (ids) => {
  return request('/member/cart', 'delete', { ids })
}

// 修改商品规格及选中状态
export const updateCart = (goods) => {
  return request('/member/cart/' + goods.skuId, 'put', goods)
}

// 全选与反选
export const checkAllCart = ({ selected, ids }) => {
  return request('/member/cart/selected', 'put', { selected, ids })
}
